package TestThread;

public class demo3 {
    public static int result;
    public static void main(String[] args) throws InterruptedException {
        Thread mainThread = Thread.currentThread();
        Thread thread = new Thread(() -> {
            try {
                mainThread.join();
                System.out.println(result);
                System.out.println("新线程结束");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
/*            System.out.println(result);
            System.out.println("新线程结束");*/
        });
        thread.start();
        for (int i = 0; i <= 10000; i++) {
            result += i;
            Thread.sleep(1);
        }
    }
}
